package com.yuexun.beilunpatient.ui.question.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.base.BaseKJActivity;
import com.yuexun.beilunpatient.baselistener.ICallBackListener;
import com.yuexun.beilunpatient.ui.question.ui.fragment.Frag_Answered;
import com.yuexun.beilunpatient.ui.question.ui.fragment.Frag_To_Reply;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2018/3/22 0022.
 */

public class Act_Question extends BaseKJActivity {

    @Bind(R.id.to_reply)
    TextView toReply;
    @Bind(R.id.to_reply_img)
    ImageView toReplyImg;
    @Bind(R.id.answered)
    TextView answered;
    @Bind(R.id.answered_img)
    ImageView answeredImg;

    KJFragment fragAnswered;
    KJFragment fragToReply;
    ICallBackListener backListener;

    public void setOnCallBack(ICallBackListener backListener) {
        this.backListener = backListener;
    }

    @Override
    public void setRootView() {
        setContentView(R.layout.act_question);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        fragToReply = new Frag_To_Reply();
        fragAnswered = new Frag_Answered();
        setOnCallBack((ICallBackListener) fragToReply);
        changeFragment(R.id.question_content, fragToReply);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.title_back, R.id.add_question, R.id.to_reply_ll, R.id.answered_ll})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
            case R.id.add_question:
                startActivity(new Intent(aty, Act_Question_Add.class));
                break;
            case R.id.to_reply_ll:
                toReply.setTextColor(getResources().getColor(R.color.main_text_02));
                toReplyImg.setBackgroundColor(getResources().getColor(R.color.main_text_02));
                answered.setTextColor(getResources().getColor(R.color.txt_black1));
                answeredImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                setOnCallBack((ICallBackListener) fragToReply);
                changeFragment(R.id.question_content, fragToReply);
                break;
            case R.id.answered_ll:
                toReply.setTextColor(getResources().getColor(R.color.txt_black1));
                toReplyImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                answered.setTextColor(getResources().getColor(R.color.main_text_02));
                answeredImg.setBackgroundColor(getResources().getColor(R.color.main_text_02));
                setOnCallBack((ICallBackListener) fragAnswered);
                changeFragment(R.id.question_content, fragAnswered);
                break;
        }
    }
}
